perm filename MON11C.PAL[SYS,HE] blob sn#144672 filedate 1975-02-07 generic text, type T, neo UTF8
COMMENT ⊗   VALID 00008 PAGES 
RECORD PAGE   DESCRIPTION
 00001 00001
 00002 00002	.TITLE PDP-11 Hand/Eye Monitor for window correlation
 00005 00003	.SBTTL	useful macros and initialization of traps
 00006 00004	.SBTTL	program initialization
 00008 00005	.SBTTL	TTY output routines
 00010 00006	.SBTTL	interrupt handler - very simple for now
 00012 00007	.SBTTL	SPS-41 control and inserted code
 00014 00008	.SBTTL	constants and variables
 00017 ENDMK
⊗;
.TITLE PDP-11 Hand/Eye Monitor for window correlation
.SBTTL	control bits and definitions for interface

; PROGRAM DEFINITIONS

ERRTRP=4		;time out and error trap
IGLINS=10		;illegal instruction
CLKTRP=104		;clock trap
PS=177776		;processor status word
KBIS=177560		;keyboard input status
KBIR=177562		;keyboard input register
KBOS=177564		;keyboard output status
KBOR=177566		;keyboard output register
CLKCNT=172544		;clock counter
CLKSET=172542		;clock set register
CLKS=172540		;clock status

STRT11=500		;starting address of program
IBUF=150		;start of input buffer from 11
OBUF=160		;start of output buffer to 11 
HCOR=77776		;highest useable word in core

;PDP11 COMMAND NUMBERS

TRNBLK=1		;transmit block
BLKSTAT=2		;get block status
REPACK=3		;repack picture block
CORWIN=4		;correlate  window
TRACK=5			;track feature
FETFND=6		;find feature

;REGISTER DEFINITIONS

PC=%7			;program counter
SP=%6			;stack ponter
NEW=%5			;new block ID or address (in STRUCT)
OLD=%4			;old block ID or address (in STRUCT)
LENG=%3			;block length (in STRUCT)
C=%2			;temp
B=%1			;temp
A=%0			;temp

;INDEX DEFINITIONS FOR PICTURE BLOCKS

PPNTR=0			;index of start of image in bytes
PSIZE=2			;size of image in bytes
LEFT=4			;first sample # in the line
TOP=6			;first line # in image
NSAMP=10		;samples per line
NLIN=12			;number of lines in image
BITS=14			;bits per sample
WRDLIN=16		;words per line
.SBTTL	useful macros and initialization of traps

.MACRO OUTSTR B			; type string starting at B
	JSR A,TYPSTR
	.WORD B
.ENDM

.MACRO CRLF			; type CRLF
	OUTSTR CRLFX
.ENDM

.MACRO NUMOCT B			; type octal  number in word B
	JSR A,TYPOCT
	.WORD B
.ENDM

.MACRO NUMDEC B			; type decimal  number in word B
	JSR A,TYPDEC
	.WORD B
.ENDM

.MACRO TTYIN B			; input a character into word (or reg.) B
	TSTB KBIS
	BEQ .-4
	MOV KBIR,B
	BIC #200,B
.ENDM

.=ERRTRP			;error trap dispatch

	ERRADR
	340

.=IGLINS			;illegal instruction dispatch

	IGLADR
	340

.=CLKTRP			;clock trap dispatch

	CLKIN
	340
.SBTTL	program initialization

.=200			;starting point from console (if not clobbered)
	JMP START

.=STRT11		;this is another starting point (for programs)
	JMP START

CLKIN:	CLR CLKCNT	;clear clock registers- trap restart
	CLR CLKSET
	CLR CLKS
START:	RESET
	MOV #500,SP	;initialize stack
	JSR PC,GRONK	;reset SPS-41 to good state
	CLR SPSDON	;SPS ready flag
	CLR PS		;initialize processor status
	JSR 5,TRPNIT	;initialize trap catcher
	.WORD 200	; first word not trapped
	JSR PC,FNDEND	;set end of free storage
	JSR PC,DATINT	;initialize data structure
	CLR OBUF+2	;clear return command number
	OUTSTR MONNAM	;tell who we are
	MOV #-1,OBUF	;signal we are ready for input
WAITX:	TST OBUF	;wait for input from 10
	BNE WAITX
	MOV IBUF,COMAND	;save command to return
	MOV COMAND,A	;test if known
	BLT COMERR
	CMP A,#6
	BLE COMOK
COMERR:	MOV #-1,OBUF	;command error - set to -1 and wait
	CLR OBUF+4
	BR WAITX
COMOK:	ASL A		;dispatch on command
	JMP @COMND(A)

COMND:			;dispatch table
	START		;reset
	COM1		;create block
	COM2		;find block
	COM3		;repack picture block
	COMERR		;correlate window
	COM5		;track feature
	COM6		;find feature
.SBTTL	TTY output routines

;	Output a string, ending with a zero character. Pointer to start
;	of string follows call. Link through A rather than PC.

TYPSTR:	MOV B,-(SP)
	MOV C,-(SP)
	MOV (A)+,C
	MOVB (C)+,B
TLOOP:	JSR PC,TYPCHR
	MOVB (C)+,B
	BGT TLOOP
	MOV (SP)+,C
	MOV (SP)+,B
	RTS A

;	output number pointed to by word following call. Link through A.

TYPDEC: MOV #10.,RADIX
	BR TYPIT
TYPOCT:	MOV #8,RADIX
TYPIT:	MOV B,-(SP)
	MOV C,-(SP)
	MOV @(A)+,B
	MOV A,-(SP)
	JSR PC,TYPDIG
	MOV (SP)+,A
	MOV (SP)+,C
	MOV (SP)+,B
	RTS A

TYPDIG:	CLR A		;	standard recursive number printer
	DIV (PC)+,A
RADIX:	10
	BEQ TYPOUT
	MOV B,-(SP)
	MOV A,B
	JSR PC,TYPDIG
	MOV (SP)+,B
TYPOUT:	ADD #'0,B
TYPCHR:	TSTB KBOS
	BPL TYPCHR
	MOVB B,KBOR
	CMP #12,B
	BNE TYPEXT
	CLR B
	JSR PC,TYPCHR
	JSR PC,TYPCHR
	JSR PC,TYPCHR
TYPEXT:	RTS PC
.SBTTL	interrupt handler - very simple for now

ERRADR:	MOV A,AA	;here is the error trap routine
	MOV #ERRMES,A	;error message
	BR JNTADR

IGLADR:	MOV A,AA	;here is the igl instruction trap routine
	MOV #IGLMES,A
JNTADR:	SPL 0		;reset processor level (there ARE no errors)
	MOV A,ERRTYP	;save error message
	MOV B,AB	; save all accumulators for possible inspection
	MOV C,AC
	MOV LENG,ALENG
	MOV OLD,AOLD
	MOV NEW,ANEW
	MOV SP,ASPX
	MOV PC,APC
	JSR A,TYPSTR
ERRTYP:	CRLFX
	MOV (SP),TRPADR
HLTLAB:	NUMOCT TRPADR
	CRLF
	HALT
	BR HLTLAB

BADTRP:	SPL 0		;trap check routine - unknow trap occured
	MOV A,AA
	MOV B,AB
	MOV C,AC
	MOV LENG,ALENG
	MOV OLD,AOLD
	MOV NEW,ANEW
	MOV SP,ASPX
	MOV PC,APC
	OUTSTR TRPERR
	MOV (SP),TRPADR
	SUB #4,TRPADR
	NUMOCT TRPADR
	OUTSTR TRPFRM
	MOV 4(SP),TRPADR
	SUB #2,TRPADR
	BR HLTLAB
.SBTTL	SPS-41 control and inserted code

; Dwell waiting for SPS-41. Message end in A.

DWELL:	MOV A,WOUT		;save message
DLOOPA:	CLR B
DLOOP:	TST SPSDON
	BEQ DOUT		;SPS is done
	CCC			;count up to overflow
	INC B
	BVC DLOOP
	CRLF			;looping - type message
	OUTSTR DMES
	JSR A,TYPSTR		;and where it came from
WOUT:	CRLFX
	CRLF
TOUT:	OUTSTR TTYINS		;tell user his options
	CRLF
	TTYIN CHR		;get his response
	CRLF			;echo for him
	CMP #'C,CHR
	BEQ DLOOPA		;wait longer
	CMP #'R,CHR
	BNE TOUT		;illegal character
	JSR PC,GRONK		;restart SPS-41
	ADD #2,(SP)		;flush return
	CLR SPSDON
	JMP @RESADR		;jump to restart address

DOUT:	RTS PC

.INSRT STRUCT.PAL[SYS,HE]
				; insert data structure routines
.INSRT TRACK.PAL[SYS,HE]
				; insert track command
.INSRT FEATUR.PAL[SYS,HE]
 				; insert feature extractor
.INSRT DEBUG.PAL[SYS,HE]

SCORE:	0			;correlation score
PAR:				;parameter block for correlation
	.BLKW 5
R0=%0
R4=%4				;define these for BO
R5=%5

.INSRT CORREL.PAL[11,SYS]
;  .INSRT COR11.PAL[SYS,HE]
				; insert correlation routine
.INSRT CATCH.PAL[SYS,HE]
				; insert trap catcher
.EVEN
.SBTTL	constants and variables

ERRMES:
	.ASCIZ /
		ERROR TRAP OCCURED BEFORE /
IGLMES:
	.ASCIZ /
		ILLEGAL INTRUCTION TRAP OCCURED BEFORE /
CRLFX:
	.ASCIZ /
/

DMES:
	.ASCIZ /DWELL LOOPING - /
TTYINS:
	.ASCIZ /TYPE C TO CONTINUE WAITING, R TO RESTART SPS-41/
FREMES:
	.ASCIZ / BYTES FREE CORE AVAILABLE/
TRPERR:
	.ASCIZ /UNKNOWN TRAP AT /
TRPFRM:
	.ASCIZ / FROM /
.EVEN

; accumulator storage

AA:	0
AB:	0
AC:	0
AD:
ALENG:	0
AOLD:	0
ANEW:	0
ASPX:	0
APC:	0

CHR:	0		;last character typed
RESADR:	0		;current restart address for SPS-41 calls
			;  must be at same subr level as call to dwell
TRPADR:	0		;hold address of trap
COMAND:	0		;hold command currently or last executed
STRUSE:	0		;pointer to first data block
ENDUSE:	0		;pointer to last data block
STRFRE:	0		;pointer to start of free storage
ENDFRE:	0		;pointer to end of free storage
DELFLG:	0		;number of deleted blocks

FREE=.			;start of free core

.END START